#!/usr/bin/python
# -*- coding: UTF-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import os
import cv2
import time
import traceback
import numpy as np


def gaussian_filter(input_image, kernel_size=3, sigma=0.):
    """
    # ksize越大，图像越模糊
    # sigma越大时，原点的取值越小，周围点的取值更大，对应到图像上中心点的权重越低，周围点权重越高，所以sigma越大图像越模糊
    """
    return cv2.GaussianBlur(input_image, (kernel_size, kernel_size), sigma)


def mean_filter(input_image, kernel_size=3):
    return cv2.blur(input_image, (kernel_size, kernel_size))


def median_filter(input_image, kernel_size=3):
    return cv2.medianBlur(input_image, kernel_size)


def bilateral_filter(input_image, kernel_size=3, sigma_color=1):
    """
    # sigmaColor和sigmaSpace参数比较小的时候( < 10)，平滑的效果不是很明显，
    # 当参数比较大或者多次平滑后的图像看起来会比较卡通化
    # 亮度差的sigma参数
    # 空间距离的sigma参数，同时作用于图像的X和Y(行、列)2个方向；
    """
    sigma_space = sigma_color
    return cv2.bilateralFilter(input_image, kernel_size, sigma_color, sigma_space)


# if __name__ == "__main__":
#     path = r'C:\Users\admin\Desktop\dt\test.bmp'  # place path to your image here
#     image_cv = cv2.imread(path, -1)
#     cv2.imshow("original", image_cv)
#     cv2.waitKey(0)
#     gau = gaussian_filter(image_cv, kernel_size=51, sigma=0.3)
#     cv2.imshow("gau", gau)
#     cv2.waitKey(0)


















